package cn.sinata.wanglin.model;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;

/**
 * 图片数据实体
 */
public class Image implements Serializable {

    @SerializedName("imgUrl")
    private String url;//网络url地址或者本地路径
    private int width;//宽度
    private int height;//高度
    private String scale ="1";
//    private float ratio = 1;//宽高比

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public float getRatio() {
        try {
           return Float.parseFloat(scale);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return 1;
        }
    }

    public void setScale(String scale) {
        this.scale = scale;
    }

    @Override
    public String toString() {
        return "Image{" +
                "url='" + url + '\'' +
                ", width=" + width +
                ", height=" + height +
                ", scale='" + scale + '\'' +
                '}';
    }
}
